import { http } from "@/utils/http";
import { baseAdminURLApi, type PageResult } from "../utils";

export type TagVO = {
  id: number;
  name: string;
  createTime: Date;
  updateTime: Date;
};

export interface TagDTO {
  id: number;
  name: string;
}
/** 获取标签列表 */
export const getTagList = (data?: PageResult<TagVO>) => {
  return http.request<PageResult<TagVO>>("get", baseAdminURLApi("/tag"), {
    params: data
  });
};

/** 新增标签 */
export const addTag = (data?: TagDTO) => {
  return http.request<boolean>("post", baseAdminURLApi("/tag"), { data });
};

/** 修改标签 */
export const editTag = (id: number, data?: TagDTO) => {
  return http.request<boolean>("put", baseAdminURLApi(`/tag/${id}`), {
    data
  });
};

/** 删除标签 */
export const deleteTagList = (data?: Array<number>) => {
  return http.request<boolean>("delete", baseAdminURLApi("/tag"), {
    data
  });
};

/** 获取标签字典 */
export const getTagDictionary = () => {
  return http.request<Array<TagDTO>>(
    "get",
    baseAdminURLApi("/tag/options"),
    {}
  );
};
